package omit.wage.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import omit.wage.result.PageResult;
import omit.wage.dto.*;
import omit.wage.entity.Staff;
import omit.wage.mapper.StaffMapper;
import omit.wage.service.IStaffService;
import omit.wage.vo.StaffVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-06-11
 */
@Service
public class StaffServiceImpl implements IStaffService {

    @Autowired
    private StaffMapper staffMapper;

    //分页查询
    public PageResult pageQuery(StaffPageDTO staffPageDTO){
        //开始分页查询
        PageHelper.startPage(staffPageDTO.getPage(), staffPageDTO.getPageSize());

        Page<StaffVO> page = staffMapper.pageQuery(staffPageDTO);
        //对callDate进行格式化确保返回数据是"callDate": [2018, 11, 18]
        List<StaffVO> rows = page.getResult();

        long total = page.getTotal();
        return new PageResult(total, rows);
    }

    //新增数据
    public void insert(StaffModifyDTO staffModifyDTO){
        staffMapper.insert(staffModifyDTO);
    }
    //修改数据
    public void update(StaffChangeDTO staffChangeDTO){
        staffMapper.update(staffChangeDTO);
    }
    //删除数据
    public void delete(List<Integer> ids){
        staffMapper.delete(ids);
    }


}
